extension IntExtension on int {
  static int createInt(dynamic value, {required int defaultValue}) {
    if (value == null) {
      return defaultValue;
    }

    if (value is int) {
      return value;
    } else if (value is String) {
      return int.parse(value);
    }

    return defaultValue;
  }

  static int? createIntOrNull(dynamic value) {
    if (value == null) {
      return null;
    }

    if (value is int) {
      return value;
    } else if (value is String) {
      return int.parse(value);
    }

    return null;
  }
}
